hysop.operator.directional.diffusion_dir module¶
@file diffusion_dir.py Directional diffusion frontend (operator generator).
- class hysop.operator.directional.diffusion_dir.DirectionalDiffusion(fields, coeffs, variables, dt, laplacian_formulation=True, name=None, implementation=None, base_kwds=None, **kwds)[source]¶
Bases:
DirectionalSymbolic
Directional diffusion using the symbolic code generation framework.
Initialize directional diffusion frontend.
Diffusion is the net movement of regions of high concentration to neighbour regions of lower concentration, ie the evolution of a field down its gradient.
- Solves
dFi/dt = Di * laplacian(Fi)
- or
dFi/dt = div( Di * grad(Fi) )
for multiple fields Fi, where * represents elementwise multiplication, using a given time integrator, inplace.
Di can be a scalar, a vector or a matrix, see Notes.
- Parameters:
fields (array like of continuous fields.) – The fields Fi that will be diffused.
coeffs (array like of coefficients) – The diffusion coefficients Di can be scalar or tensor like (ie. possibly anisotropic). Contained values should be numerical coefficients, parameters or symbolic expressions such that Di*grad(Fi) is directionally splittable.
variables (dict) – Dictionary of fields as keys and topology descriptors as values.
dt (ScalarParameter) – Timestep parameter that will be used for time integration.
laplacian_formulation (bool, optional, defaults to True) – Use the Di*laplacian(Fi) formulation instead of the div(Di*grad(Fi)) formulation.
name (str, optional) – Name of this diffusion operator, defaults to ‘diffusion’.
implementation (Implementation, optional, defaults to None) – Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional, defaults to None) – Base class keywords arguments. If None, an empty dict will be passed.
kwds – Keywords arguments that will be passed towards implementation operator __init__.
Notes
Solves dFi/dt = div( Di * grad(Fi) ) with the following notations:
- Fi = (Fi0(x0,…,xMi),
- Fi1(x0,…,xMi),
…
FiNi(x0,…,xMi))
Mi = Fi.dim - 1 Ni = Fi.nb_components - 1
- grad(Fi) = (dFi0/dx0, …, dFi0/dxM),
- (dFi1/dx0, …, dFi1/dxM),
…
(dFiNi/dx0, …, dFiNi/dxM)
(d00, …, d0Ni) ( . . . )
- Di = ( . . . ) or (d0, …, dN) or d0
( . . . ) (dNi0, …, dNiNi)
if Di.ndim is 1, Di[:,None] will be used ie:
(d0, …, d0) ( . . . )
- Di = ( . . . )
( . . . ) (dNi, …, dNi)
if Di.ndim is 0, Di[None,None] will be used ie:
(d0, …, d0) (. . .)
- Di = (. . .)
(. . .) (d0, …, d0)